package com.zhuoshi.sevlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zhuoshi.bean.ContractReportBean;

public class ContractExportServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5079290789649554007L;

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		doPost(request, response);
	}

	@SuppressWarnings("unchecked")
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=utf-8");
		String action = request.getParameter("action");//作用域不同，接收的内容也不同，这里是我在链接地址后面加？action= 这是属于request作用域的，所以能得到
		HttpSession session = request.getSession();
		List<ContractReportBean> list = (List<ContractReportBean>) session.getAttribute("list");//而这个不能从地址栏后面的参数接收，作用域不同，一个是getParameter  而这个是getAttribute
		//System.out.println(list);
		PrintWriter writer = response.getWriter();
		for (ContractReportBean crBean : list) {
			writer.print(crBean.getNumerical() +"|" + crBean.getSqarename() + "<br/>");
		}
		writer.print("["+action+"]");
		
	}

}
